package com.etc.demo1.demo.mapper;

import com.etc.demo1.demo.domain.Order;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface OrderMapper {
    //查询全部
    @Select("select * from order")
    List<Order> findAll();

    //新增数据
    @Insert("INSERT INTO order(order.user_id,order.good_id,order.order_sum,order.remark) VALUES(#{user_id},#{good_id},#{order_sum},#{remark})")
    public int save(Order goods);

    //删除数据
    @Delete("delete from order where order_id=#{id}")
    public int delete(int id);

    //根据id查找
    @Select("select * from order where order_id=#{id}")
    public Order getById(int id);

    //更新数据
    @Update("update order set user_id=#{user_id},good_id=#{good_id},order_sum=#{order_sum},remark=#{remark} where order_id=#{order_id}")
    public int update(Order goods);
}
